<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Index extends Controller_Common {

	public $template='layout/index';

	public function action_index() {
		$this->buildCarcas();

		$this->template->slider = View::factory('pieces/slider', array(
			
		));

		$posts = Model::factory('Articles')->get_last_news();
		$pages = ceil(Model::factory('Articles')->countAll($this->getType('posts')) / $this->_config->get('items_per_page'));

		$this->template->content = View::factory('pages/index', array(
			'slider' => View::factory('pieces/slider', array(
				'slider' => DB::select('id', array('title'.$this::$postfix, 'title'), array('text'.$this::$postfix, 'text'), 'image', 'link')->from('slider')->order_by('sort', 'DESC')->limit(5)->as_object()->execute(),
			)),
			'breadcrumbs' => View::factory('pieces/breadcrumbs', array(
				'breadcrumbs' => array(
					array('active' => 1, 'title' => 'Главная', 'link' => '/')
				)
			)),
			'left_menu' => Model::factory('Menu')->get_by_location(1),
			'posts' => $posts,
			'right_banners' => Model::factory('Banners')->get_right(),
			'bot_banner' => Model::factory('Banners')->get_bot(),
			'partners' => Model::factory('Partners')->get_all(),
			'pages_count' => $pages
		));
	}

}